package com.zbl.parser;

import com.xuxueli.crawler.parser.strategy.NonPageParser;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

/**
 * @Author: zhangjun
 * @Date: 2020/7/31 11:51
 * @Description:
 */
public class TableJsoupParse extends NonPageParser {
    @Override
    public void parse(String url, String pageSource) {
        Document document = Jsoup.parse(pageSource);
        Elements trs = document.select(".resulttable tbody tr:gt(0)");
        for (int i=0;i<trs.size();i++) {
            System.out.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n",
                    trs.get(i).select("td:eq(0) a").text(),
                    trs.get(i).select("td:eq(1)").text(),
                    trs.get(i).select("td:eq(2)").text(),
                    trs.get(i).select("td:eq(3)").text(),
                    trs.get(i).select("td:eq(4)").text(),
                    trs.get(i).select("td:eq(5)").text(),
                    trs.get(i).select("td:eq(6)").text()
            );
        }
    }
}
